using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.CompanyDomain;
using ShivamEMR.Model.DataInterfaces.CompanyDataInterf;
using ShivamEMR.Model;
using ShivamEMR.Web.Models;
//using ShivamEMR.Web.Areas.Company.Models;

namespace ShivamEMR.Web.Areas.Company.Controllers
{   
    public class EmployeeStatusController : Controller
    {
		private readonly IEmployeeStatusRepository employeestatusRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public EmployeeStatusController() 
        {
            employeestatusRepository = Registry.RepositoryFactory.GetEmployeeStatusRepository();
        }

        public EmployeeStatusController(IEmployeeStatusRepository employeestatusRepository)
        {
			this.employeestatusRepository = employeestatusRepository;
        }

        //
        // GET: /EmployeeStatus/
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ViewResult Index()
        {
           // return View(employeestatusRepository.AllIncluding(employeestatus => employeestatus.Employees));
            return View(employeestatusRepository.All);
        }

        //
        // GET: /EmployeeStatus/Details/5
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ViewResult Details(int id)
        {
            return View(employeestatusRepository.Find(id));
        }

        //
        // GET: /EmployeeStatus/Create
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /EmployeeStatus/Create
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        [HttpPost]
        public ActionResult Create(EmployeeStatus employeestatus)
        {
            if (ModelState.IsValid) {
                employeestatusRepository.Create(employeestatus);
                employeestatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /EmployeeStatus/Edit/5
 [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ActionResult Edit(int id)
        {
             return View(employeestatusRepository.Find(id));
        }

        //
        // POST: /EmployeeStatus/Edit/5
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        [HttpPost]
        public ActionResult Edit(EmployeeStatus employeestatus)
        {
            if (ModelState.IsValid) {
                employeestatusRepository.Update(employeestatus);
                employeestatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /EmployeeStatus/Delete/5
 [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        public ActionResult Delete(int id)
        {
            return View(employeestatusRepository.Find(id));
        }

        //
        // POST: /EmployeeStatus/Delete/5
        [CustomAuthorizeAttribute(RequiredRight = "Admin")]
        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
          //  employeestatusRepository.Delete(id);
            var estatus = employeestatusRepository.Find(id);
            employeestatusRepository.Delete(estatus);
            employeestatusRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

